Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@antfu/install-pkg
Advanced tools
@antfu/install-pkg is a utility for programmatically installing npm packages. It simplifies the process of adding dependencies to your project by providing a straightforward API to install packages without needing to manually run npm or yarn commands.
Install a single package
This feature allows you to install a single npm package programmatically. In this example, the 'lodash' package is installed, and a message is logged upon successful installation.
const { install } = require('@antfu/install-pkg');
install('lodash').then(() => {
console.log('Lodash installed');
});
Install multiple packages
This feature allows you to install multiple npm packages at once. In this example, both 'express' and 'mongoose' packages are installed, and a message is logged upon successful installation.
const { install } = require('@antfu/install-pkg');
install(['express', 'mongoose']).then(() => {
console.log('Express and Mongoose installed');
});
Specify package version
This feature allows you to specify the version of the package you want to install. In this example, version 17.0.2 of the 'react' package is installed, and a message is logged upon successful installation.
const { install } = require('@antfu/install-pkg');
install('react@17.0.2').then(() => {
console.log('React 17.0.2 installed');
});
Install devDependencies
This feature allows you to install a package as a dev dependency. In this example, the 'typescript' package is installed as a dev dependency, and a message is logged upon successful installation.
const { install } = require('@antfu/install-pkg');
install('typescript', { dev: true }).then(() => {
console.log('TypeScript installed as a dev dependency');
});
npm-install-package is a utility for installing npm packages programmatically. It provides a simple API to install packages and can be used as an alternative to @antfu/install-pkg. However, it may not offer as many features or as clean an API as @antfu/install-pkg.
yarn-install is a utility for programmatically installing packages using Yarn. It is similar to @antfu/install-pkg but specifically designed for Yarn users. It provides a straightforward API for adding dependencies to your project using Yarn.
npmi is a simple utility for installing npm packages programmatically. It offers basic functionality for adding dependencies to your project and can be used as an alternative to @antfu/install-pkg. However, it may lack some of the advanced features provided by @antfu/install-pkg.
Install package programmatically. Detect package managers automatically (npm
, yarn
and pnpm
).
npm i @antfu/install-pkg
import { installPackage } from '@antfu/install-pkg'
await installPackage('vite', { silent: true })
MIT License © 2021 Anthony Fu
FAQs
Install package programmatically.
We found that @antfu/install-pkg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.